package com.woniu.controller.operation;

import com.woniu.controller.BaseController;
import com.woniu.entity.Result;
import com.woniu.service.IOrderService;
import com.woniu.vo.CarPlateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("//createOrder")
@Api(tags = "创建订单")
public class CreateOrder extends BaseController {

    @Autowired
    private IOrderService orderService;

    /**
     * 车辆驶入停车位时，录入车辆并创建订单。
     * @param magnetId 地磁id
     * @param carPlateVo 摄像机拍摄的车辆的车牌图片的车牌号码、车牌类型和车辆图片的文件名
     * @return 返回操作的结果
     */
    @PostMapping("//{magnetId}")
    @ApiOperation("车辆驶入停车位时，录入车辆并创建订单")
    public Result createOrder(@PathVariable Long magnetId, @RequestBody CarPlateVo carPlateVo) {
        boolean result = orderService.createOrder(magnetId, carPlateVo);
        return toResult(result);
    }

}
